package org.ens.delegation.bo;

import java.util.Date;

import javax.persistence.*;

/**
 * @author amine
 *
 */
@Entity
@Table(name="agent_grade")
public class AgentGrade implements IBusinessObject<AgentGradePK>{

	private AgentGradePK id;
	private Date dateAssignation;
	
	@Override
	@Id
	public AgentGradePK getId() {
		return id;
	}

	@Override
	public void setId(AgentGradePK pk) {
		id = pk;
	}
	
	@ManyToOne
	@JoinColumn(name="code_agen",insertable=false,updatable=false)
	public Agent getAgent() {
		return id.getAgent();
	}
	
	public void setAgent(Agent agent) {
		id.setAgent(agent);
	}
	
	@ManyToOne
	@JoinColumn(name="code_grade",insertable=false,updatable=false)
	public Grade getGrade() {
		return id.getGrade();
	}
	
	public void setGrade(Grade grade) {
		id.setGrade(grade);
	}
	
	@Column(name="date_assignation")
        @Temporal(javax.persistence.TemporalType.DATE)
	public Date getDateAssignation() {
		return dateAssignation;
	}

	public void setDateAssignation(Date dateAssignation) {
		this.dateAssignation = dateAssignation;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj == null || !(obj instanceof AgentGrade))
			return false;
		AgentGrade agentGrade = (AgentGrade) obj;
		if(agentGrade.getId() == null)
			return false;
	
		return agentGrade.getId().equals(this.getId());
	}
	
}
